<?php

/**
 * orders actions.
 *
 * @package    sf_sandbox
 * @subpackage orders
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class ordersActions extends sfActions
{
  public function executeIndex()
  {
    $this->ordersList = OrdersPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new OrdersForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new OrdersForm(OrdersPeer::retrieveByPk($request->getParameter('orders_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new OrdersForm(OrdersPeer::retrieveByPk($request->getParameter('orders_id')));

    $this->form->bind($request->getParameter('orders'));
    if ($this->form->isValid())
    {
      $orders = $this->form->save();

      $this->redirect('orders/edit?orders_id='.$orders->getOrdersId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($orders = OrdersPeer::retrieveByPk($request->getParameter('orders_id')));

    $orders->delete();

    $this->redirect('orders/index');
  }
}
